import { menu } from "../../decorator";

const { ccclass, property } = cc._decorator;

@ccclass
@menu(__filename)
export default class attributeSame extends cc.Component {
    @property([cc.Node])
    private nodes: cc.Node[] = [];

    @property({ tooltip: '组件名' })
    private component = '';

    @property({ tooltip: '属性名' })
    private attribute = '';

    setAttribute(value: any) {
        this.nodes.forEach((node) => {
            const coms = node.getComponents(this.component);
            if (coms && coms.length) {
                coms.forEach((com) => {
                    if (com !== this) {
                        com[this.attribute] = value;
                    }
                })
            }
        })
    };
}